<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of generateCoefficientEquationFromString</title>
  <meta name="keywords" content="generateCoefficientEquationFromString">
  <meta name="description" content="Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">source</a> &gt; generateCoefficientEquationFromString.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for source&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>generateCoefficientEquationFromString
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ theCoefficient ] = generateCoefficientEquationFromString( chr ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.

Prototype: [theCoefficient] = generateCoefficientEquationFromString(chr)

Input:  chr - Char equation.

Output: theCoefficient - String of coefficient.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="strsplit.html" class="code" title="function parts = strsplit( splitstr, str, option )">strsplit</a>	Split string into pieces.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="generateSymsL.html" class="code" title="function [ L ] = generateSymsL( n, m, hState, d )">generateSymsL</a>	Generate the syms matrix L.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.</span>
0002 <span class="comment">%</span>
0003 <span class="comment">%Prototype: [theCoefficient] = generateCoefficientEquationFromString(chr)</span>
0004 <span class="comment">%</span>
0005 <span class="comment">%Input:  chr - Char equation.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%Output: theCoefficient - String of coefficient.</span>
0008 
0009 <a name="_sub0" href="#_subfunctions" class="code">function [ theCoefficient ] = generateCoefficientEquationFromString( chr )</a>
0010 
0011 chr = strrep(chr, <span class="string">' '</span>, <span class="string">''</span>);
0012 chr = strrep(chr, <span class="string">'+'</span>, <span class="string">' +'</span>);
0013 chr = strrep(chr, <span class="string">'-'</span>, <span class="string">' -'</span>);
0014 pieces = <a href="strsplit.html" class="code" title="function parts = strsplit( splitstr, str, option )">strsplit</a>(<span class="string">' '</span>,chr);
0015 <span class="keyword">if</span> cellfun(@isempty, pieces(1))
0016     pieces(1) = [];
0017 <span class="keyword">end</span>
0018 
0019 i = 1;
0020 index = 1;
0021 coefficient = pieces(1);
0022 found = false;
0023 <span class="keyword">while</span> i &lt;= length(pieces)
0024     actualPiece = pieces(i);
0025     <span class="keyword">if</span> cellfun(@isempty,strfind(actualPiece,<span class="string">'/'</span>))==true
0026         coefficient(index) = actualPiece;
0027         index = index+1;
0028         found = true;
0029     <span class="keyword">end</span>
0030     i = i + 1;
0031 <span class="keyword">end</span>
0032 
0033 <span class="keyword">if</span> found == true
0034     theCoefficient = char(coefficient(1));
0035     match = 2;
0036     <span class="keyword">while</span> match &lt;= length(coefficient)
0037         theCoefficient = strcat(theCoefficient,char(coefficient(match)));
0038         match = match + 1;
0039     <span class="keyword">end</span>
0040 <span class="keyword">else</span>
0041     theCoefficient = 0;
0042 <span class="keyword">end</span>
0043 
0044 <span class="keyword">return</span>;
0045 
0046 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 12-Oct-2009 21:15:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>